<template>
  死亡日期：<el-date-picker style="width: 100px" v-model="form.start">
  </el-date-picker
  ><el-date-picker style="width: 100px" v-model="form.end"> </el-date-picker
  >&emsp;&emsp; 后裔耳号：<el-select
    style="width: 200px"
    placeholder="请选择"
    v-model="form.sleepInforId"
  >
    <el-option
      v-for="item in SelectEar"
      :label="item.earNumber"
      :value="item.sleepInforId"
    />
  </el-select>
  <el-button type="danger" size="large" @click="gettableData()">查询</el-button>
  <br />
  <hr style="font-size: 20px" />
  <br />
  <el-table height="400" border style="width: 100%" :data="tableData">
    <el-table-column type="selection" />
    <el-table-column prop="descendantsId" label="序号" />
    <el-table-column prop="descendantsDate" label="转种日期">
      <template v-slot="scope">
        {{ scope.row.descendantsDate.substring(0, 19).replace('T', ' ') }}
      </template>
    </el-table-column>
    <el-table-column prop="earNumber" label="育成羊耳号" />
    <el-table-column prop="currentBarn" label="当前栋舍" />
    <el-table-column prop="currentPen" label="当前栏位" />
    <el-table-column prop="transferBarn" label="转入栋舍" />
    <el-table-column prop="transferPen" label="转入栏位" />
    <el-table-column prop="gender" label="性别">
      <template v-slot="scope">
        <span v-if="scope.row.gender == 1">公</span>
        <span v-if="scope.row.gender == 2">母</span>
      </template>
    </el-table-column>
    <el-table-column prop="ageDay" label="转种日龄"> </el-table-column>
    <el-table-column prop="createId" label="创建人">
      <template #default="scope">
        <span v-if="scope.row.createId == 1">罗Sir</span>
      </template>
    </el-table-column>
    <el-table-column prop="createTime" label="创建时间">
      <template v-slot="scope">
        {{ scope.row.createTime.substring(0, 19).replace('T', ' ') }}
      </template>
    </el-table-column>
    <el-table-column prop="updateId" label="修改人" />
    <el-table-column prop="updateTime" label="修改时间">
      <template v-slot="scope">
        {{
          scope.row.updateTime == null
            ? ''
            : scope.row.updateTime.substring(0, 19).replace('T', ' ')
        }}
      </template>
    </el-table-column>
    <!-- <el-table-column prop="name" fixed="right" width="120" label="操作">
      <template #default="scope"> </template>
    </el-table-column> -->
  </el-table>
</template>

<script setup lang="ts">
import {
  Check,
  Delete,
  Edit,
  Message,
  Back,
  Plus,
  Setting,
  SuccessFilled,
  Minus,
  Close,
} from '@element-plus/icons-vue';
import { reactive, ref, onMounted, computed } from 'vue';
import axios from 'axios';
import { useRoute, useRouter } from 'vue-router';
import { ElMessage, ElMessageBox } from 'element-plus';
import { useCounterStore } from '@/stores/counter';
const counterStore = useCounterStore();
const route = useRoute();
const router = useRouter();

//定义变量
const form = reactive({
  start: '',
  end: '',
  sleepInforId: '',
});

const tableData = ref([]);
const gettableData = () => {
  axios
    .post('http://localhost:5039/api/Descendantsafte/Handle1', {
      start: form.start || '',
      end: form.end || '',
      sleepInforId: form.sleepInforId || 0,
    })
    .then((res) => {
      console.log(res.data);
      tableData.value = res.data.data;
    });
};

//获取耳号
const SelectEar = ref<any>([]);
const geteweData = () => {
  axios.get('http://localhost:5039/api/SleepBegin/SelectEar').then((res) => {
    SelectEar.value = res.data.item;
  });
};

onMounted(() => {
  geteweData();
  gettableData();
});
</script>

<style scoped>
.demo-pagination-block + .demo-pagination-block {
  margin-top: 10px;
}

.demo-pagination-block .demonstration {
  margin-bottom: 16px;
}
</style>
